package com.dingding.service.core.special.service.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import com.dingding.common.core.beans.special.SpecialDrivingRecord;
import com.dingding.common.core.util.ToolUtil;
import com.dingding.facade.user.common.dto.special.driver.ReqSpecialDrivingRecord;
import com.dingding.facade.user.common.dto.special.driver.ResOrderMileageCost;
import com.dingding.service.core.special.dao.ISpecialDrivingRecordDao;
import com.dingding.service.core.special.service.ISpecialDrivingRecordService;

/**
 * 
 * @ClassName: SpecialDrivingRecordServiceImpl 
 * @Description: 车辆行车记录业务逻辑实现类
 * @author YHQ
 * @date 2016年12月8日 上午9:39:51
 * @since V2.5.7
 * 
 */
@Component("specialDrivingRecordService")
public class SpecialDrivingRecordServiceImpl implements ISpecialDrivingRecordService {

	@Resource(name = "specialDrivingRecordDao")
	private ISpecialDrivingRecordDao specialDrivingRecordDao;
	
	/**
	 * 
	 * @Title: getSpecialDrivingRecored 
	 * @Description: 获取专车司机行车记录表（最近一次记录）
	 * @param reqSpecialDrivingRecord 获取专车司机行车记录表请求Bean
	 * @author YHQ 
	 * @since V2.5.7
	 * @return SpecialDrivingRecord    返回类型
	 * 
	 */
	@Override
	public SpecialDrivingRecord getSpecialDrivingRecored(ReqSpecialDrivingRecord reqSpecialDrivingRecord) {
		
		// 验证请求参数是否为空
		if(reqSpecialDrivingRecord == null || !ToolUtil.validateParam(reqSpecialDrivingRecord)){
			
			return null;
		}
		
		// 查询
		return specialDrivingRecordDao.getSpecialDrivingRecored(reqSpecialDrivingRecord.getUserId(), reqSpecialDrivingRecord.getOrderId());
	}

	/**
	 * 
	 * @Title: saveSpecialDrivingRecored 
	 * @Description: 保存专车司机行车记录表
	 * @param specialDrivingRecord 司机行车记录对象
	 * @author YHQ 
	 * @since V2.5.7
	 * @return boolean    返回类型
	 * 
	 */
	@Override
	public boolean saveSpecialDrivingRecored(SpecialDrivingRecord specialDrivingRecord) {
		
		// 验证客户端请求参数
		if(specialDrivingRecord == null || !ToolUtil.validateParam(specialDrivingRecord)){
			return false;
		}
		
		return specialDrivingRecordDao.saveSpecialDrivingRecored(specialDrivingRecord);
	}

	/**
	 * 
	 * @Title: getOrderMileageCost 
	 * @Description: 实时计算订单里程以及价格
	 * @param reqSpecialDrivingRecord 客户端请求参数
	 * @author YHQ 
	 * @since V2.5.7
	 * @return ResOrderMileageCost    返回类型
	 * 
	 */
	@Override
	public ResOrderMileageCost getOrderMileageCost(ReqSpecialDrivingRecord reqSpecialDrivingRecord) {
		
		// 验证客户端请求参数
		if(reqSpecialDrivingRecord == null || !ToolUtil.validateParam(reqSpecialDrivingRecord)){
			return null;
		}
		
		return specialDrivingRecordDao.getOrderMileageCost(reqSpecialDrivingRecord.getUserId(), reqSpecialDrivingRecord.getOrderId());
	}

}
